home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dviselect / scanpost.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-16  |  2.1 KB  |  99 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. #ifndef lint
  8. static char rcsid[] = "$Header: scanpost.c,v 1.1 88/02/11 17:08:55 jim Exp $";
  9. #endif
  10.  
  11. /*
  12.  * ScanPostAmble - read a DVI postamble.
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include "types.h"
  17. #include "dvicodes.h"
  18. #include "fio.h"
  19. #include "postamble.h"
  20.  
  21. ScanPostAmble(f, headerfunc, fontfunc)
  22.     register FILE *f;
  23.     int (*headerfunc)();
  24.     register int (*fontfunc)();
  25. {
  26.     register int n;
  27.     register char *s;
  28.     char name[512];
  29.  
  30.     if (FindPostAmble(f))
  31.         GripeCannotFindPostamble();
  32.     if (GetByte(f) != Sign8(DVI_POST))
  33.         GripeMissingOp("POST");
  34.  
  35.     /* Read the postamble info stuff. */
  36.     {
  37.         struct PostAmbleInfo pai;
  38.         register struct PostAmbleInfo *p = &pai;
  39.  
  40.         p->pai_PrevPagePointer = GetLong(f);
  41.         p->pai_Numerator = GetLong(f);
  42.         p->pai_Denominator = GetLong(f);
  43.         p->pai_DVIMag = GetLong(f);
  44.         p->pai_TallestPageHeight = GetLong(f);
  45.         p->pai_WidestPageWidth = GetLong(f);
  46.         p->pai_DVIStackSize = GetWord(f);
  47.         p->pai_NumberOfPages = GetWord(f);
  48.  
  49.         (*headerfunc)(p);
  50.     }
  51.  
  52.     /* Now read all the font definitions. */
  53.     {
  54.         struct PostAmbleFont paf;
  55.         register struct PostAmbleFont *p = &paf;
  56.  
  57.         for (;;) {
  58.             switch (UnSign8(getc(f))) {
  59.  
  60.             case DVI_FNTDEF1:
  61.                 p->paf_DVIFontIndex = UnSign8(getc(f));
  62.                 break;
  63.  
  64.             case DVI_FNTDEF2:
  65.                 p->paf_DVIFontIndex = UnSign16(GetWord(f));
  66.                 break;
  67.  
  68.             case DVI_FNTDEF3:
  69.                 p->paf_DVIFontIndex = UnSign24(Get3Byte(f));
  70.                 break;
  71.  
  72.             case DVI_FNTDEF4:
  73.                 p->paf_DVIFontIndex = GetLong(f);
  74.                 break;
  75.  
  76.             case DVI_POSTPOST:
  77.                 return;
  78.  
  79.             default:
  80.                 GripeMissingOp("POSTPOST");
  81.                 /*NOTREACHED*/
  82.             }
  83.             p->paf_DVIChecksum = GetLong(f);
  84.             p->paf_DVIMag = GetLong(f);
  85.             p->paf_DVIDesignSize = GetLong(f);
  86.             p->paf_n1 = UnSign8(getc(f));
  87.             p->paf_n2 = UnSign8(getc(f));
  88.             p->paf_name = name;    /* never trust people not to
  89.                            clobber it */
  90.             n = p->paf_n1 + p->paf_n2;
  91.             s = name;
  92.             while (--n >= 0)
  93.                 *s++ = GetByte(f);
  94.             *s = 0;
  95.             (*fontfunc)(p);
  96.         }
  97.     }
  98. }
  99.